#ifndef CLIENT_MANAGER_H
#define CLIENT_MANAGER_H

#include <libwebsockets.h>

typedef struct Client {
    struct lws *wsi;
    char username[50];
    char secret_key[65];
    int is_logged_in;
    int is_authenticated; // 新增认证状态
    int user_id;          // 新增用户ID
} Client;

typedef struct {
    Client *clients;      // 保持值数组
    int client_count;
    int capacity;
} VHostData;

void init_vhost_data(VHostData *vhd);
void add_client(VHostData *vhd, Client *client);
void remove_client(VHostData *vhd, struct lws *wsi);
void broadcast_message(VHostData *vhd, const char *message, struct lws *sender);
int get_logged_in_count(VHostData *vhd);
void update_client_in_vhd(VHostData *vhd, Client *client); // 新增函数

#endif